import { FormProps, FormSchema } from '@/components/Table'
import { BasicColumn } from '@/components/Table/src/types/table'
import { pattern } from '@/utils/validate/index'
import dayjs, { Dayjs } from 'dayjs'
import api from '@/api'
const { queryPackageList } = api

export function getBasicColumns(): BasicColumn[] {
  return [
    {
      title: '订单编号',
      fixed: 'left',
      dataIndex: 'buyNo'
    },
    {
      title: '用户手机号',
      width: 100,
      dataIndex: 'phoneNumber'
    },
    {
      title: '关联企业名称',
      width: 140,
      customEllipsis: true,
      dataIndex: 'enterpriseName'
    },
    {
      title: '关联企业税号',
      width: 120,
      dataIndex: 'taxNo'
    },
    {
      title: '套餐类型',
      width: 120,
      customEllipsis: true,
      dataIndex: 'packageName'
    },
    {
      title: '用户类型',
      width: 80,
      dataIndex: 'buyType'
    },
    {
      title: '订单金额',
      align: 'right',
      width: 110,
      dataIndex: 'payAmt'
    },
    {
      title: '所属渠道',
      width: 150,
      customEllipsis: true,
      dataIndex: 'channelName'
    },
    {
      title: '缴款方式',
      width: 90,
      dataIndex: 'payType'
    },
    {
      title: '下单时间',
      width: 140,
      dataIndex: 'createTime'
    },
    {
      title: '订单状态',
      width: 100,
      dataIndex: 'orderStatus'
    },
    {
      title: '订单属性',
      width: 80,
      dataIndex: 'orderType'
    },
    {
      title: '原订单/退款订单编号',
      width: 160,
      customEllipsis: true,
      dataIndex: 'associateBuyNo'
    },
    {
      title: '操作',
      width: 60,
      fixed: 'right',
      dataIndex: 'operate'
    }
  ]
}

export function getSearchFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    baseColProps: {
      span: 6,
      md: 10,
      xl: 8,
      xxl: 6
    },
    schemas: [
      {
        field: 'buyNo',
        label: '订单编号',
        component: 'Input'
      },
      {
        field: 'phoneNumber',
        label: '手机号',
        component: 'Input'
      },
      {
        field: 'packageCode',
        label: '套餐类型',
        component: 'ApiSelect',
        componentProps: {
          api: queryPackageList,
          resultField: 'result',
          labelField: 'packageName',
          valueField: 'packageCode',
          showSearch: true,
          immediate: true,
          optionFilterProp: 'label'
        }
      },
      {
        field: 'channelNoList',
        label: '所属渠道',
        component: 'TreeSelect',
        slot: 'channelCode'
      }
    ]
  }
}
